function hienForm(div){
   
    (div.attr("width")) ? w = div.attr("width") : w = div.width();
    (div.attr("height")) ? h = div.attr("height") : h = div.height();      
    
    var box = $("<div></div>").addClass("darkCover");
    $("body").prepend(box);
    box.fadeTo("fast",0.8);
    
    var contentBox = $("<div></div>").html(div.html());
    contentBox.addClass("darkContent");
    $("body").prepend(contentBox);
    
            
    var type = "bounceLeft";
    
    switch(type){
                

            
        case "bounceLeft":
            var x = $(window).width()/2;
            var y = $(window).height()/2 - h/2;
            contentBox.css({"left": "0px" , "top" : "0px" ,"z-index" : "10" , "padding" : "0px"});
            contentBox.css({"width" : "0px" , "height" : "0px","overflow":"hidden"});
            contentBox.animate({left:x} ,{queue :false ,duration :2000 ,easing :"linear"})
            .animate({top:y} ,3000 ,"easeOutBounce",function(){
                contentBox.animateOut({
                    easing :"easeInExpo",
                    endWidth :w,
                    endHeight :h,
                    dir :"center",
                    speed :500,
                    endPadding:8
                });        
            });
            break;
        
    }
};
        
(function($){
    $.fn.animateOut = function(options){
        var defaults = {
            dir : "center",
            speed :5000,//mili giay
            easing : "linear",
            endPadding :0
        };  
        
        var options = $.extend(defaults,options);
        
        return this.each(function(){
            
            (options.endHeight) ? h = options.endHeight : h = $(this).height();
            (options.endWidth) ? w = options.endWidth : w = $(this).width();
            y = $(this).position().top;
            
            switch(options.dir){
                case "x" :
                    x = $(this).position().left - w/2;
                    startLeft = x + w/2;
                    startTop = y;
                    startWidth = 0;
                    startHeight = h;
                    break;
                    
                case "y":
                    x = $(this).position().left;
                    startLeft = x;
                    startTop = y + h/2;
                    startWidth = w;
                    startHeight = 0;
                    break;
                case  "center" :
                default:
                    x = $(this).position().left - w/2;
                    startLeft = x + w/2;
                    startTop = y + h/2;
                    startWidth = 0;
                    startHeight = 0;
                    break;                    
            }
            
            $(this).css("left",startLeft);
            $(this).css("top",startTop);
            $(this).css("width",startWidth);
            $(this).css("height",startHeight);
            $(this).css("padding",0);
            
            $(this).animate({
                width :"220px" ,
                height : "200px",
                top : "100px",
                left : "360px",
                opacity:1,
                padding : options.endPadding,
                borderBottomColor : "black",
                borderTopColor : "black",
                borderLeftColor : "black",
                borderRightColor : "black" ,               
            },options.speed,options.easing);
            
        });
    };
    
})(jQuery);  